#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar xh,qian,bai,shi,ge,xsxh;
uint time;
uchar code table[]={
0xC0,0xf9,0xA4,0xB0,
0x99,0x92,0x82,0xF8,
0x80,0x90,0x88,0x83,
0xC6,0xA1,0x86,0x8E};
sbit key=P2^4;
sbit fwkey=P2^5;
sbit fmq=P3^6;
sbit P2_0=P2^0;
sbit P2_1=P2^1;
sbit P2_2=P2^2;
sbit P2_3=P2^3;
void delay(uint z);
void shownum(uchar qian,uchar bai,uchar shi,uchar ge,uchar cyc,uchar time);
void main()
{
	key=1;
	fwkey=1;
	while(1)
	{
		if(key==0)
		{
			delay(100);
			if(key==0)
			{
				while(!key);
				while(key)
				{
					time++;
					delay(10);
				}
			}
		}
		qian=time/1000;
		bai=time%1000/100;
		shi=time%100/10;
		ge=time%10;
		shownum(qian,bai,shi,ge,100,5);
	}
}
void delay (uint z)
{
	uint x,y;
	for(x=z;x>0;x--)
		for(y=11;y>0;y--);
}
void shownum(uchar qian,uchar bai,uchar shi,uchar ge,uchar cyc,uchar time)
{
for(xsxh=0;xsxh<cyc;xsxh++)
		{
			//qbsg
			P0=table[qian];
			P2_0=0;
			delay(time);
			P2_0=1;
			P0=table[bai];
			P2_1=0;
			delay(time);
			P2_1=1;
			P0=table[shi];
			P2_2=0;
			delay(time);
			P2_2=1;
			P0=table[ge];
			P2_3=0;
			delay(time);
			P2_3=1;
		}
}